﻿<Window x:Class="SoftTeach.View.Noten.NotenlistenDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:SoftTeach.Resources.Controls"
        xmlns:local="clr-namespace:SoftTeach.ViewModel.Noten"
        xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        Title="Noten eingeben ..." 
        Height="660" 
        Width="765"
        WindowState="Maximized">
  <Window.Resources>
    <CollectionViewSource x:Key="SchülerViewSource" Source="{Binding Path=CurrentSchülerliste.Schülereinträge}">
      <CollectionViewSource.SortDescriptions>
        <componentModel:SortDescription PropertyName="SchülereintragSortByNachnameProperty" Direction="Ascending" />
      </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>
    <CollectionViewSource x:Key="VorhandeneNotenlistenViewSource" Source="{Binding Path=NotenlistenEinträge}">
      <CollectionViewSource.SortDescriptions>
        <componentModel:SortDescription PropertyName="Termin" Direction="Ascending" />
      </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>

  </Window.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Border Name="SurroundBorder" Grid.Row="0" CornerRadius="2" BorderBrush="White" BorderThickness="1" Background="{StaticResource BannerBackgroundBrush}">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="48"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Image VerticalAlignment="Center" Grid.Column="0" Name="icon" Width="32" Height="32" Margin="8" Source="/SoftTeach;component/Images/Logo64.png" />
        <TextBlock VerticalAlignment="Center" Grid.Column="1" Text="{Binding Path=DialogTitle}" Foreground="White" FontSize="14" TextWrapping="Wrap" Margin="5"/>
      </Grid>
    </Border>
    <ToolBarTray Grid.Row="1" IsLocked="True">
      <ToolBar>
        <RadioButton Style="{StaticResource {x:Static ToolBar.RadioButtonStyleKey}}" Click="ZwischenstandClick" ToolTip="Zwischenstand anlegen" 
                     IsChecked="{Binding Path=NotenTermintyp, Converter={StaticResource EnumBooleanConverter}, ConverterParameter={x:Static local:NotenTermintyp.Zwischenstand}}">
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Note32.png" />
              <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Zwischenstand anlegen</Label>
          </StackPanel>
        </RadioButton>
        <RadioButton Style="{StaticResource {x:Static ToolBar.RadioButtonStyleKey}}" Click="HalbjahrClick"  ToolTip="Halbjahreszeugnis anlegen" 
                     IsChecked="{Binding Path=NotenTermintyp, Converter={StaticResource EnumBooleanConverter}, ConverterParameter={x:Static local:NotenTermintyp.Halbjahr}}">
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Halbjahre32.png" />
              <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Halbjahreszeugnis anlegen</Label>
          </StackPanel>
        </RadioButton>
        <RadioButton Style="{StaticResource {x:Static ToolBar.RadioButtonStyleKey}}" Click="GanzjahrClick" ToolTip="Jahreszeugnis anlegen"
                     IsChecked="{Binding Path=NotenTermintyp, Converter={StaticResource EnumBooleanConverter}, ConverterParameter={x:Static local:NotenTermintyp.Ganzjahr}}">
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Schuljahr32.png" />
              <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Jahreszeugnis anlegen</Label>
          </StackPanel>
        </RadioButton>
        <Separator/>
        <RadioButton Style="{StaticResource {x:Static ToolBar.RadioButtonStyleKey}}" Click="ModifyClick" ToolTip="Notenlisten ändern">
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Note32.png" />
              <Image Source="/SoftTeach;component/Images/EditOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Notenlisten ändern</Label>
          </StackPanel>
        </RadioButton>
        <Separator/>
        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=PrintNotenlisteCommand}" ToolTip="Notenliste drucken.">
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Note32.png"/>
              <Image Source="/SoftTeach;component/Images/PrintOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Notenliste drucken</Label>
          </StackPanel>
        </Button>

      </ToolBar>
    </ToolBarTray>
    <Grid Grid.Row="2" Background="{StaticResource DefaultOfficeBackgroundBrush}">
      <Grid Margin="10">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
          <HeaderedContentControl Name="VorhandeneNotenlistenControl" Visibility="Collapsed">
            <HeaderedContentControl.Header>
              <Label>Vorhandene Notenlisten</Label>
            </HeaderedContentControl.Header>
            <ListBox 
              MinHeight="40" Opacity="0.7"
                 ItemsSource="{Binding Source={StaticResource VorhandeneNotenlistenViewSource}}"             
                 BorderThickness="0"
                 SelectedItem="{Binding CurrentNotenlistenEintrag}"
                 Name="ZeugnisNotenListBox"
                 ItemTemplate="{StaticResource NotenlisteneintragView}">
              <ListBox.InputBindings>
                <KeyBinding Key="Delete" Command="{Binding Path=DeleteNotenlisteCommand}"/>
              </ListBox.InputBindings>
              <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                  <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
              </ListBox.ItemsPanel>
            </ListBox>
          </HeaderedContentControl>
          <StackPanel Orientation="Horizontal">
            <!--<Label Content="Noten für"/>
            <RadioButton Name="ZwischenstandRadio"  Content="Zwischenstand" IsChecked="{Binding Path=NotenTermintyp, Converter={StaticResource EnumBooleanConverter}, ConverterParameter={x:Static local:NotenTermintyp.Zwischenstand}}"  Margin="6"/>
            <RadioButton Name="HalbjahrRadio" Content="Halbjahr" IsChecked="{Binding Path=NotenTermintyp, Converter={StaticResource EnumBooleanConverter}, ConverterParameter={x:Static local:NotenTermintyp.Halbjahr}}"  Margin="6"/>
            <RadioButton Name="GanzjahrRadio" Content="Ganzjahresnote" IsChecked="{Binding Path=NotenTermintyp, Converter={StaticResource EnumBooleanConverter}, ConverterParameter={x:Static local:NotenTermintyp.Ganzjahr}}"  Margin="6"/>-->
            <Label Content="{Binding Path=DatumsLabel}"/>
            <DatePicker x:Name="DatePicker" SelectedDate="{Binding Path=Notendatum, Mode=TwoWay}"/>
          </StackPanel>
          <Label/>
        </StackPanel>
        <ListBox Grid.Row="1" Background="Transparent" 
                 ItemsSource="{Binding Source={StaticResource SchülerViewSource}}"             
                 BorderThickness="0"
                 Name="NotenlisteListBox"
                 ItemTemplate="{StaticResource ZeugnisNotenView}">
          <ListBox.InputBindings>
            <KeyBinding Key="Delete" Command="{Binding Path=DeleteNotenlisteCommand}"/>
          </ListBox.InputBindings>
          <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
              <WrapPanel Orientation="Vertical" Height="{Binding ElementName=NotenlisteListBox, Path=ActualHeight, Converter={StaticResource WrapPanelWidthConverter}}"/>
            </ItemsPanelTemplate>
          </ListBox.ItemsPanel>
        </ListBox>
      </Grid>
    </Grid>
    <Grid Background="{StaticResource DefaultButtonsBackgroundBrush}" Grid.Row="3">
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
        <Button Name="NeuButton" Width="100" HorizontalAlignment="Right" Click="NeuClick" TabIndex="2">Neu anlegen</Button>
        <Button Name="ÄndernButton" Width="100" Margin="5,0,0,0" HorizontalAlignment="Right" Click="ÄndernClick" TabIndex="2" Visibility="Collapsed">Ändern</Button>
        <Button Width="100" Margin="5,0,0,0" HorizontalAlignment="Right" IsCancel="True" Click="CancelClick" TabIndex="3">Abbruch</Button>
      </StackPanel>
    </Grid>
  </Grid>
</Window>
